
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>leetCode周赛记录 · 计算机 ,java , 大数据 基础知识体系</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="hzh">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="1.时间复杂度.html" />
    
    
    <link rel="prev" href="../数据结构/9.模板.html" />
    

    
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">操作系统</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../操作系统/1.基本概述.html">
            
                <a href="../操作系统/1.基本概述.html">
            
                    
                    1.操作系统基本概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../操作系统/2.进程管理之进程与线程.html">
            
                <a href="../操作系统/2.进程管理之进程与线程.html">
            
                    
                    2.进程管理之进程与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../操作系统/3.进程管理之处理机调度.html">
            
                <a href="../操作系统/3.进程管理之处理机调度.html">
            
                    
                    3.进程管理之处理机调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../操作系统/4.进程管理之进程同步.html">
            
                <a href="../操作系统/4.进程管理之进程同步.html">
            
                    
                    4.进程管理之进程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../操作系统/5.内存管理之基本概念.html">
            
                <a href="../操作系统/5.内存管理之基本概念.html">
            
                    
                    5.内存管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../操作系统/6.内存管理之虚拟内存.html">
            
                <a href="../操作系统/6.内存管理之虚拟内存.html">
            
                    
                    6.内存管理之虚拟内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../操作系统/7.IO设备管理之基本概念.html">
            
                <a href="../操作系统/7.IO设备管理之基本概念.html">
            
                    
                    7.IO设备管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../操作系统/8.面试题总结一.html">
            
                <a href="../操作系统/8.面试题总结一.html">
            
                    
                    8.面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">计算机网络篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../计算机网络/1.计算机网络入门基础概念.html">
            
                <a href="../计算机网络/1.计算机网络入门基础概念.html">
            
                    
                    1.计算机网络入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../计算机网络/2.计算机网络通信基础.html">
            
                <a href="../计算机网络/2.计算机网络通信基础.html">
            
                    
                    2.计算机网络通信入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../计算机网络/3.数据链路层.html">
            
                <a href="../计算机网络/3.数据链路层.html">
            
                    
                    3.数据链路层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../计算机网络/4.网络层1.html">
            
                <a href="../计算机网络/4.网络层1.html">
            
                    
                    4.网络层(一)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../计算机网络/5.网络层2.html">
            
                <a href="../计算机网络/5.网络层2.html">
            
                    
                    5.网络层(二)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../计算机网络/6.传输层.html">
            
                <a href="../计算机网络/6.传输层.html">
            
                    
                    6.传输层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../计算机网络/7.应用层.html">
            
                <a href="../计算机网络/7.应用层.html">
            
                    
                    7.应用层(⭐)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../计算机网络/10.HTTP相关协议.html">
            
                <a href="../计算机网络/10.HTTP相关协议.html">
            
                    
                    8.HTTP相关及发展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" >
            
                <span>
            
                    
                    9.websocket
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../计算机网络/9.面试题二.html">
            
                <a href="../计算机网络/9.面试题二.html">
            
                    
                    面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">数据结构篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../数据结构/1.图论.html">
            
                <a href="../数据结构/1.图论.html">
            
                    
                    1.图论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../数据结构/2.图论例题.html">
            
                <a href="../数据结构/2.图论例题.html">
            
                    
                    2.图论例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../数据结构/3.散列表.html">
            
                <a href="../数据结构/3.散列表.html">
            
                    
                    3.散列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../数据结构/4.排序算法.html">
            
                <a href="../数据结构/4.排序算法.html">
            
                    
                    4.排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../数据结构/5.排序列题.html">
            
                <a href="../数据结构/5.排序列题.html">
            
                    
                    5.排序算法例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../数据结构/6.树论.html">
            
                <a href="../数据结构/6.树论.html">
            
                    
                    6.树论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../数据结构/7.树论例题.html">
            
                <a href="../数据结构/7.树论例题.html">
            
                    
                    7.树论例题.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../数据结构/9.模板.html">
            
                <a href="../数据结构/9.模板.html">
            
                    
                    数据结构模板
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">算法篇</li>
        
        
    
        <li class="chapter active" data-level="4.1" data-path="leetCode周赛题解.html">
            
                <a href="leetCode周赛题解.html">
            
                    
                    leetCode周赛记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="1.时间复杂度.html">
            
                <a href="1.时间复杂度.html">
            
                    
                    1.时间复杂度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="2.深度优先搜索.html">
            
                <a href="2.深度优先搜索.html">
            
                    
                    2.深度优先搜索算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="2.深度优先搜索题目集.html">
            
                <a href="2.深度优先搜索题目集.html">
            
                    
                    2.深搜题目集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="3.广度优先搜索.html">
            
                <a href="3.广度优先搜索.html">
            
                    
                    3.广度优先搜索算法
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JVM篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../jvm/1.jvm内存结构.html">
            
                <a href="../jvm/1.jvm内存结构.html">
            
                    
                    1.jvm内存结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                <a href="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                    
                    2.HotSpot虚拟机对象探秘.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../jvm/3.对象存亡与垃圾收集算法.html">
            
                <a href="../jvm/3.对象存亡与垃圾收集算法.html">
            
                    
                    3.对象存亡与垃圾收集算法.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                <a href="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                    
                    4.HotSpot的算法细节与垃圾收集器.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../jvm/5.内存分配与回收策略.html">
            
                <a href="../jvm/5.内存分配与回收策略.html">
            
                    
                    5.内存分配与回收策略.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../jvm/6.类文件结构.html">
            
                <a href="../jvm/6.类文件结构.html">
            
                    
                    6.类文件结构.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../jvm/7.类加载机制.html">
            
                <a href="../jvm/7.类加载机制.html">
            
                    
                    7.类加载机制.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../jvm/8.jvm逃逸分析.html">
            
                <a href="../jvm/8.jvm逃逸分析.html">
            
                    
                    8.逃逸分析技术
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">多线程篇</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../多线程/basic/0.多线程路线图.html">
            
                <a href="../多线程/basic/0.多线程路线图.html">
            
                    
                    1.多线程学习路线图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../多线程/basic/0.java内存模型与线程.html">
            
                <a href="../多线程/basic/0.java内存模型与线程.html">
            
                    
                    2.java内存模型与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../多线程/3.并行程序基础.html">
            
                <a href="../多线程/3.并行程序基础.html">
            
                    
                    2.并行程序基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                <a href="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                    
                    3.happenBefore与jvm指令重排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../多线程/basic/1.synchronized与volatile.html">
            
                <a href="../多线程/basic/1.synchronized与volatile.html">
            
                    
                    4.synchronized与volatile.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="../多线程/basic/2.ThreadLocal.html">
            
                <a href="../多线程/basic/2.ThreadLocal.html">
            
                    
                    5.ThreadLocal.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="../多线程/cas/1.乐观锁与悲观锁.html">
            
                <a href="../多线程/cas/1.乐观锁与悲观锁.html">
            
                    
                    6.乐观锁与悲观锁.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="../多线程/cas/2.CAS与atomic类.html">
            
                <a href="../多线程/cas/2.CAS与atomic类.html">
            
                    
                    7.CAS与atomic类.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="../多线程/aqs/1.AQS.html">
            
                <a href="../多线程/aqs/1.AQS.html">
            
                    
                    8.AQS.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="../多线程/aqs/2.基于AQS的并发工具.html">
            
                <a href="../多线程/aqs/2.基于AQS的并发工具.html">
            
                    
                    9.基于AQS的并发工具.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="../多线程/blockingQueue/1.阻塞队列.html">
            
                <a href="../多线程/blockingQueue/1.阻塞队列.html">
            
                    
                    10.阻塞队列.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="../多线程/pond/1.线程池与底层原理.html">
            
                <a href="../多线程/pond/1.线程池与底层原理.html">
            
                    
                    11.线程池与底层原理.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="../多线程/10面试题一.html">
            
                <a href="../多线程/10面试题一.html">
            
                    
                    12.面试题一
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="../多线程/10面试题二.html">
            
                <a href="../多线程/10面试题二.html">
            
                    
                    13.面试题二.md
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">java集合篇</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../basic/collection/1.java集合.html">
            
                <a href="../basic/collection/1.java集合.html">
            
                    
                    1.集合架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../basic/collection/2.HashMap源码分析.html">
            
                <a href="../basic/collection/2.HashMap源码分析.html">
            
                    
                    2.hashMap底层原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../basic/collection/3.ConcurrentHashMap分析.html">
            
                <a href="../basic/collection/3.ConcurrentHashMap分析.html">
            
                    
                    3.ConcurrentHashMap分析
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">设计模式篇</li>
        
        
    
        <li class="chapter " data-level="8.1" >
            
                <span>
            
                    
                    1.创造型模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="../设计模式/factory/三种工厂模式介绍.html">
            
                <a href="../设计模式/factory/三种工厂模式介绍.html">
            
                    
                    三种工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="../设计模式/factory/实战工厂模式.html">
            
                <a href="../设计模式/factory/实战工厂模式.html">
            
                    
                    实战工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="../设计模式/factory/实战抽象工厂模式.html">
            
                <a href="../设计模式/factory/实战抽象工厂模式.html">
            
                    
                    实战抽象工厂模式
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">mysql篇</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../数据库/mysql/1.b树b+树的底层原理.html">
            
                <a href="../数据库/mysql/1.b树b+树的底层原理.html">
            
                    
                    1.mysql索引基础之b树与b+树⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../数据库/mysql/2.mysql索引.html">
            
                <a href="../数据库/mysql/2.mysql索引.html">
            
                    
                    2.mysql索引及优化⭐⭐⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../数据库/mysql/3.mysql存储引擎.html">
            
                <a href="../数据库/mysql/3.mysql存储引擎.html">
            
                    
                    3.mysql存储引擎.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                <a href="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                    
                    4.多版本并发控制之mvcc原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="../数据库/mysql/4.mysql事务.html">
            
                <a href="../数据库/mysql/4.mysql事务.html">
            
                    
                    5.mysql事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.6" data-path="../数据库/mysql/5.mysql锁机制.html">
            
                <a href="../数据库/mysql/5.mysql锁机制.html">
            
                    
                    6.mysql的锁机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.7" data-path="../数据库/mysql/6.mysql面试题一.html">
            
                <a href="../数据库/mysql/6.mysql面试题一.html">
            
                    
                    7.mysql面试题一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高并发中间件篇</li>
        
        
    

    
        
        <li class="header">架构理论篇</li>
        
        
    
        <li class="chapter " data-level="11.1" data-path="../架构/0.架构演进.html">
            
                <a href="../架构/0.架构演进.html">
            
                    
                    1.架构演进
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="11.2" data-path="../架构/0.微服务架构与soa架构.html">
            
                <a href="../架构/0.微服务架构与soa架构.html">
            
                    
                    2.微服务架构与soa架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高可用系统篇</li>
        
        
    
        <li class="chapter " data-level="12.1" data-path="../高可用架构/1.限流.html">
            
                <a href="../高可用架构/1.限流.html">
            
                    
                    1.系统限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="../高可用系统/2.服务熔断.html">
            
                <a href="../高可用系统/2.服务熔断.html">
            
                    
                    2.服务熔断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.3" data-path="../高可用系统/3.服务降级.html">
            
                <a href="../高可用系统/3.服务降级.html">
            
                    
                    3.服务降级
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">spring-cloud 微服务篇</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >leetCode周赛记录</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;"><b></b>&#x7B2C; 220&#x573A;&#x5468;&#x8D5B;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;"><a name="&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;" class="anchor-navigation-ex-anchor" href="#&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;" class="plugin-anchor" href="#&#x7B2C;-220&#x573A;&#x5468;&#x8D5B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7B2C; 220&#x573A;&#x5468;&#x8D5B;</h3>
<h4 id="1&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;"><a name="1&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;" class="anchor-navigation-ex-anchor" href="#1&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;" class="plugin-anchor" href="#1&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a>1.<a href="https://leetcode-cn.com/problems/maximum-erasure-value/" target="_blank">&#x5220;&#x9664;&#x5B50;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x5927;&#x5F97;&#x5206;</a></h4>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201220195724.png" alt="image-20201220195724922"></p>
<p><strong>&#x9898;&#x76EE;&#x5206;&#x6790;</strong></p>
<p>&#x8FD9;&#x9898;&#x6709;&#x5F88;&#x660E;&#x786E;&#x7684;&#x9898;&#x610F;:&#x5BFB;&#x627E;&#x4E00;&#x4E2A;&#x7A97;&#x53E3;,&#x6CA1;&#x6709;&#x91CD;&#x590D;&#x6570;&#x5B57;,&#x548C;&#x4E3A;&#x6240;&#x6709;&#x7A97;&#x53E3;&#x7684;&#x6700;&#x5927;&#x503C;</p>
<p>&#x6240;&#x4EE5;&#x5F88;&#x660E;&#x663E;&#x53EF;&#x4EE5;&#x7528;&#x6ED1;&#x52A8;&#x7A97;&#x53E3;&#x89E3;&#x9898;</p>
<pre><code class="lang-c++"><span class="hljs-keyword">class</span> Solution {
<span class="hljs-keyword">public</span>:
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">maximumUniqueSubarray</span><span class="hljs-params">(<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; nums)</span> </span>{
    <span class="hljs-keyword">int</span> ans=<span class="hljs-number">0</span>;
    <span class="hljs-built_in">set</span>&lt;<span class="hljs-keyword">int</span>&gt; st;
    <span class="hljs-keyword">int</span> temp=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">int</span> left=<span class="hljs-number">0</span>,right=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">while</span>(right&lt;nums.size())
    {
        <span class="hljs-keyword">int</span> curR=nums[right++];
        <span class="hljs-keyword">if</span>(st.find(curR)==st.end())
        {
            temp+=curR;
            ans=max(ans,temp);
            st.insert(curR);
        }
        <span class="hljs-keyword">else</span>
        {
            <span class="hljs-keyword">while</span>(curR!=nums[left])
            {
                temp-=nums[left];
                st.erase(st.find(nums[left]));
                left++;
            }
            <span class="hljs-comment">//&#x8FD9;&#x91CC;&#x4E0D;&#x7528;&#x518D;&#x5220;&#x9664;&#x533A;&#x95F4;&#x91CC;&#x76F8;&#x540C;&#x7684;&#x5143;&#x7D20;&#x4E86;,&#x56E0;&#x4E3A;curR&#x5E76;&#x6CA1;&#x6709;&#x88AB;&#x52A0;&#x5230;temp&#x4E2D;</span>
            left++;
        }
    }
    <span class="hljs-keyword">return</span> ans;
}
};
</code></pre>
<h4 id="2&#x8DF3;&#x8DC3;&#x6E38;&#x620F;-vi"><a name="2&#x8DF3;&#x8DC3;&#x6E38;&#x620F;-vi" class="anchor-navigation-ex-anchor" href="#2&#x8DF3;&#x8DC3;&#x6E38;&#x620F;-vi"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x8DF3;&#x8DC3;&#x6E38;&#x620F;-vi" class="plugin-anchor" href="#2&#x8DF3;&#x8DC3;&#x6E38;&#x620F;-vi"><i class="fa fa-link" aria-hidden="true"></i></a>2.<a href="https://leetcode-cn.com/problems/jump-game-vi/" target="_blank">&#x8DF3;&#x8DC3;&#x6E38;&#x620F; VI</a></h4>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201220202010.png" alt="image-20201220202010091"></p>
<h5 id="&#x89E3;&#x6CD5;&#x4E00;"><a name="&#x89E3;&#x6CD5;&#x4E00;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6CD5;&#x4E00;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x89E3;&#x6CD5;&#x4E00;" class="plugin-anchor" href="#&#x89E3;&#x6CD5;&#x4E00;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6CD5;&#x4E00;</h5>
<p>&#x8FD9;&#x9053;&#x9898;&#x65E0;&#x975E;&#x5C31;&#x662F;dp</p>
<p>&#x90A3;&#x4E48;&#x5F88;&#x660E;&#x663E;&#xFF0C;&#x6BCF;&#x6B21;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x627E;&#x5230;dp[i - 1]&#x3001;dp[i - 2]&#x3001;...&#x3001;dp[i - k]&#x7684;&#x6700;&#x5927;&#x503C;&#xFF0C;&#x7136;&#x540E;&#x52A0;&#x4E0A;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7684;&#x5927;&#x5C0F;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5F97;&#x5230;dp[i]&#x3002;</p>
<p>&#x4F46;&#x662F;&#x7B80;&#x5355;&#x7684;dp&#x4F1A;&#x8D85;&#x65F6;!!!!!</p>
<p>&#x4E8E;&#x662F;,&#x6211;&#x4EEC;&#x60F3;&#x5230;,&#x53EF;&#x4EE5;&#x7528;&#x7EBF;&#x6BB5;&#x6811;&#x6765;&#x6C42;&#x533A;&#x95F4;&#x7684;&#x6700;&#x5927;&#x503C;,&#x5E76;&#x4E14;&#x6C42;&#x5B8C;dp[i]&#x4E4B;&#x540E;,&#x8981;&#x6CE8;&#x610F;&#x4FEE;&#x6539;&#x7EBF;&#x6BB5;&#x6811;&#x7684;&#x533A;&#x95F4;&#x503C;</p>
<pre><code class="lang-c++"><span class="hljs-meta">#&#x7EBF;&#x6BB5;&#x6811;&#x6A21;&#x677F;    </span>
<span class="hljs-keyword">class</span> NumArray {
<span class="hljs-keyword">public</span>:
    <span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> ls k&lt;&lt;1</span>
    <span class="hljs-meta">#<span class="hljs-meta-keyword">define</span>  rs k&lt;&lt;1|1</span>
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; t;
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; nums;
    <span class="hljs-keyword">int</span> size;
    NumArray(<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; nums) {
        size=nums.size();
        t=<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;(size*<span class="hljs-number">4</span>+<span class="hljs-number">1</span>,<span class="hljs-number">0</span>);
        <span class="hljs-keyword">this</span>-&gt;nums=nums;
        build(<span class="hljs-number">1</span>,<span class="hljs-number">0</span>,size<span class="hljs-number">-1</span>);
    }
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">update_point</span><span class="hljs-params">(<span class="hljs-keyword">int</span> p,<span class="hljs-keyword">int</span> v)</span>
    </span>{
        update(<span class="hljs-number">1</span>,<span class="hljs-number">0</span>,size<span class="hljs-number">-1</span>,p,v);
    }
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">getMax</span><span class="hljs-params">(<span class="hljs-keyword">int</span> i,<span class="hljs-keyword">int</span> j)</span>
    </span>{
        <span class="hljs-keyword">return</span> query_max(<span class="hljs-number">1</span>,<span class="hljs-number">0</span>,size<span class="hljs-number">-1</span>,i,j);
    }
    <span class="hljs-comment">//////////////////////////////////////</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">pushUp</span><span class="hljs-params">(<span class="hljs-keyword">int</span> k)</span>
    </span>{
        t[k]=max(t[ls],t[rs]);
    }
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">build</span><span class="hljs-params">(<span class="hljs-keyword">int</span> k,<span class="hljs-keyword">int</span> l,<span class="hljs-keyword">int</span> r)</span>
    </span>{
        <span class="hljs-keyword">if</span>(l==r)
        {
            t[k]=nums[l];
        }
        <span class="hljs-keyword">else</span>
        {
            <span class="hljs-keyword">int</span> m=l+(r-l)/<span class="hljs-number">2</span>;
            build(ls,l,m);
            build(rs,m+<span class="hljs-number">1</span>,r);
            pushUp(k);
        }
    }
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">query_max</span><span class="hljs-params">(<span class="hljs-keyword">int</span> k,<span class="hljs-keyword">int</span> l,<span class="hljs-keyword">int</span> r,<span class="hljs-keyword">int</span> L,<span class="hljs-keyword">int</span> R)</span>
    </span>{
        <span class="hljs-keyword">if</span> (l&gt;=L&amp;&amp;r&lt;=R)
            <span class="hljs-keyword">return</span> t[k];
        <span class="hljs-keyword">else</span>
        {
            <span class="hljs-keyword">int</span> left=INT_MIN,right=INT_MIN;
            <span class="hljs-keyword">int</span> m=l+(r-l)/<span class="hljs-number">2</span>;
            <span class="hljs-keyword">if</span>(L&lt;=m)
                left=query_max(ls,l,m,L,R);
            <span class="hljs-keyword">if</span>(R&gt;m)
                right=query_max(rs,m+<span class="hljs-number">1</span>,r,L,R);
            <span class="hljs-keyword">return</span> max(left,right);
        }
    }
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">update</span><span class="hljs-params">(<span class="hljs-keyword">int</span> k,<span class="hljs-keyword">int</span> l,<span class="hljs-keyword">int</span> r,<span class="hljs-keyword">int</span> p,<span class="hljs-keyword">int</span> v)</span>
    </span>{
        <span class="hljs-keyword">if</span>(l==r)
        {
            t[k]=v;
        }
        <span class="hljs-keyword">else</span>
        {
            <span class="hljs-keyword">int</span> m=l+(r-l)/<span class="hljs-number">2</span>;
            <span class="hljs-keyword">if</span>(p&lt;=m)
                update(ls,l,m,p,v);
            <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(p&gt;m)
                update(rs,m+<span class="hljs-number">1</span>,r,p,v);
            pushUp(k);
        }
    }
};


<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">maxResult</span><span class="hljs-params">(<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; nums, <span class="hljs-keyword">int</span> k)</span> </span>{
    <span class="hljs-keyword">int</span> size=nums.size();
    <span class="hljs-keyword">if</span>(size==<span class="hljs-number">0</span>)
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
    <span class="hljs-function">NumArray <span class="hljs-title">numArray</span><span class="hljs-params">(nums)</span></span>;
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; dp(size+<span class="hljs-number">1</span>,<span class="hljs-number">0</span>);
    dp[<span class="hljs-number">0</span>]=nums[<span class="hljs-number">0</span>];
    numArray.update_point(<span class="hljs-number">0</span>,dp[<span class="hljs-number">0</span>]);
    <span class="hljs-comment">//&#x5BF9;&#x4E8E;&#x6BCF;&#x4E2A;&#x70B9;,&#x6C42;&#x5176;&#x4E4B;&#x524D;&#x7684;[i-k,i-1]&#x533A;&#x95F4;&#x4E2D;&#x7684;&#x6700;&#x5927;&#x503C;</span>
    <span class="hljs-comment">//&#x6C42;&#x5B8C;&#x4E4B;&#x540E;&#x66F4;&#x65B0;&#x7EBF;&#x6BB5;&#x6811;</span>
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;size;i++)
    {
        <span class="hljs-keyword">int</span> left=i-k&gt;=<span class="hljs-number">0</span>?i-k:<span class="hljs-number">0</span>;
        <span class="hljs-keyword">int</span> right=i<span class="hljs-number">-1</span>;
        dp[i]=numArray.getMax(left,right)+nums[i];
        numArray.update_point(i,dp[i]);
        <span class="hljs-built_in">cout</span>&lt;&lt;dp[i]&lt;&lt;<span class="hljs-string">&quot; &quot;</span>;
    }
    <span class="hljs-built_in">cout</span>&lt;&lt;<span class="hljs-built_in">endl</span>;
    <span class="hljs-keyword">return</span> dp[size<span class="hljs-number">-1</span>];
}
</code></pre>
<h5 id="&#x89E3;&#x6CD5;&#x4E8C;"><a name="&#x89E3;&#x6CD5;&#x4E8C;" class="anchor-navigation-ex-anchor" href="#&#x89E3;&#x6CD5;&#x4E8C;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x89E3;&#x6CD5;&#x4E8C;" class="plugin-anchor" href="#&#x89E3;&#x6CD5;&#x4E8C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x89E3;&#x6CD5;&#x4E8C;</h5>
<p>&#x4E0A;&#x9762;&#x7684;&#x89E3;&#x6CD5;&#x6211;&#x4EEC;&#x7528;&#x5230;&#x4E86;&#x7EBF;&#x6BB5;&#x6811;,&#x4F46;&#x662F;&#x6548;&#x7387;&#x5E76;&#x4E0D;&#x9AD8;</p>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x7528;&#x540C;&#x6837;&#x7684;&#x601D;&#x8DEF;,&#x53EA;&#x662F;&#x7EBF;&#x6BB5;&#x6811;&#x53D8;&#x6210;&#x4E86;&#x5355;&#x8C03;&#x6808;</p>
<p>&#x4E5F;&#x5373;&#x6211;&#x4EEC;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A;&#x5355;&#x8C03;&#x9012;&#x51CF;&#x6808;,&#x90A3;&#x4E48;&#x533A;&#x95F4;[i-k,i-1]&#x7684;&#x6700;&#x5927;&#x503C;&#x5C31;&#x662F;&#x6808;&#x5934;</p>
<pre><code class="lang-c++"><span class="hljs-keyword">class</span> Solution {
<span class="hljs-keyword">public</span>:
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">maxResult</span><span class="hljs-params">(<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; nums, <span class="hljs-keyword">int</span> k)</span> </span>{
    <span class="hljs-keyword">int</span> ans=<span class="hljs-number">0</span>;
    <span class="hljs-built_in">deque</span>&lt;<span class="hljs-keyword">int</span>&gt; dq;
    <span class="hljs-keyword">int</span> size=nums.size();
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; dp(size,<span class="hljs-number">0</span>);
    dp[<span class="hljs-number">0</span>]=nums[<span class="hljs-number">0</span>];
    dq.push_back(<span class="hljs-number">0</span>);
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;size;i++)
    {
        <span class="hljs-comment">//&#x5411;&#x53F3;&#x6ED1;&#x52A8;,&#x5220;&#x9664;i-k-1</span>
        <span class="hljs-keyword">if</span>(i&gt;k&amp;&amp;i-k<span class="hljs-number">-1</span>==dq.front())dq.pop_front();
        <span class="hljs-keyword">int</span> cur=nums[i];
        dp[i]=dp[dq.front()]+cur;
        <span class="hljs-comment">//&#x5355;&#x8C03;&#x9012;&#x51CF;&#x7684;&#x903B;&#x8F91;</span>
        <span class="hljs-keyword">while</span>(!dq.empty()&amp;&amp;dp[dq.back()]&lt;dp[i])dq.pop_back();
        dq.push_back(i);
    }
    <span class="hljs-keyword">return</span> dp[size<span class="hljs-number">-1</span>];
}
};
</code></pre>
<h4 id="3&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;"><a name="3&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;" class="anchor-navigation-ex-anchor" href="#3&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;" class="plugin-anchor" href="#3&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;"><i class="fa fa-link" aria-hidden="true"></i></a>3.<a href="https://leetcode-cn.com/problems/checking-existence-of-edge-length-limited-paths/" target="_blank">&#x68C0;&#x67E5;&#x8FB9;&#x957F;&#x5EA6;&#x9650;&#x5236;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;&#x5B58;&#x5728;</a></h4>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201220204404.png" alt="image-20201220204403986"></p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201220204417.png" alt="image-20201220204417345"></p>
<p><strong>&#x5E76;&#x67E5;&#x96C6; + &#x79BB;&#x7EBF;&#x601D;&#x7EF4;</strong></p>
<p>&#x300C;&#x79BB;&#x7EBF;&#x300D;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF0C;&#x5BF9;&#x4E8E;&#x4E00;&#x9053;&#x9898;&#x76EE;&#x4F1A;&#x7ED9;&#x51FA;&#x82E5;&#x5E72;&#x8BE2;&#x95EE;&#xFF0C;&#x800C;&#x8FD9;&#x4E9B;&#x8BE2;&#x95EE;&#x662F;&#x5168;&#x90E8;&#x63D0;&#x524D;&#x7ED9;&#x51FA;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x4F60;&#x4E0D;&#x5FC5;&#x6309;&#x7167;&#x8BE2;&#x95EE;&#x7684;&#x987A;&#x5E8F;&#x4F9D;&#x6B21;&#x5BF9;&#x5B83;&#x4EEC;&#x8FDB;&#x884C;&#x5904;&#x7406;&#xFF0C;&#x800C;&#x662F;&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x67D0;&#x79CD;&#x987A;&#x5E8F;&#xFF08;&#x4F8B;&#x5982;&#x5168;&#x5E8F;&#x3001;&#x504F;&#x5E8F;&#xFF08;&#x62D3;&#x6251;&#x5E8F;&#xFF09;&#x3001;&#x6811;&#x7684; DFS &#x5E8F;&#x7B49;&#xFF09;&#x6216;&#x8005;&#x628A;&#x6240;&#x6709;&#x8BE2;&#x95EE;&#x770B;&#x6210;&#x4E00;&#x4E2A;&#x6574;&#x4F53;&#xFF08;&#x4F8B;&#x5982;&#x6574;&#x4F53;&#x4E8C;&#x5206;&#x3001;&#x83AB;&#x961F;&#x7B97;&#x6CD5;&#x7B49;&#xFF09;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;</p>
<p>&#x4E0E;&#x300C;&#x79BB;&#x7EBF;&#x300D;&#x76F8;&#x5BF9;&#x5E94;&#x7684;&#x662F;&#x300C;&#x5728;&#x7EBF;&#x300D;&#x601D;&#x7EF4;&#xFF0C;&#x5373;&#x6240;&#x6709;&#x7684;&#x8BE2;&#x95EE;&#x662F;&#x4F9D;&#x6B21;&#x7ED9;&#x51FA;&#x7684;&#xFF0C;&#x5728;&#x8FD4;&#x56DE;&#x7B2C; kk &#x4E2A;&#x8BE2;&#x95EE;&#x7684;&#x7B54;&#x6848;&#x4E4B;&#x524D;&#xFF0C;&#x4E0D;&#x4F1A;&#x83B7;&#x5F97;&#x7B2C; k+1k+1 &#x4E2A;&#x8BE2;&#x95EE;&#x3002;</p>
<p>&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;&#x529B;&#x6263;&#x5E73;&#x53F0;&#x4E0A;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7684;&#x9898;&#x76EE;&#x90FD;&#x662F;&#x300C;&#x79BB;&#x7EBF;&#x300D;&#x7684;&#xFF0C;&#x5373;&#x4E00;&#x6B21;&#x6027;&#x7ED9;&#x51FA;&#x6240;&#x6709;&#x7684;&#x8BE2;&#x95EE;&#x3002;&#x4F46;&#x5728;&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x6309;&#x7167;&#x4E0B;&#x6807;&#x987A;&#x5E8F;&#x5904;&#x7406;&#x8FD9;&#x4E9B;&#x8BE2;&#x95EE;&#x662F;&#x6CA1;&#x6709;&#x95EE;&#x9898;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x7528;&#x300C;&#x5728;&#x7EBF;&#x300D;&#x7684;&#x601D;&#x7EF4;&#x5728;&#x300C;&#x79BB;&#x7EBF;&#x300D;&#x7684;&#x573A;&#x666F;&#x4E0B;&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x3002;&#x7136;&#x800C;&#x5BF9;&#x4E8E;&#x672C;&#x9898;&#x800C;&#x8A00;&#xFF0C;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x6309;&#x7167;&#x4E00;&#x5B9A;&#x7684;&#x987A;&#x5E8F;&#x5904;&#x7406; \textit{queries}queries &#x4E2D;&#x7684;&#x8BE2;&#x95EE;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x4F7F;&#x5F97;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x6CA1;&#x6709;&#x4FDD;&#x8BC1;&#x3002;</p>
<p>&#x672C;&#x9898;&#x9700;&#x8981;&#x7684;&#x524D;&#x7F6E;&#x6280;&#x80FD;&#x70B9;&#x4E3A;&#x300C;&#x5E76;&#x67E5;&#x96C6;&#x300D;&#xFF0C;&#x5982;&#x679C;&#x8BFB;&#x8005;&#x6CA1;&#x6709;&#x638C;&#x63E1;&#xFF0C;&#x53EF;&#x4EE5;&#x5C1D;&#x8BD5;&#x67E5;&#x9605;&#x76F8;&#x5173;&#x8D44;&#x6599;&#x8FDB;&#x884C;&#x5B66;&#x4E60;&#x3002;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201220210001.png" alt="image-20201220210001363"></p>
<pre><code class="lang-c++"><span class="hljs-keyword">class</span> UF{

<span class="hljs-keyword">private</span>:
    <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt; parent;

<span class="hljs-keyword">public</span>:
    UF(<span class="hljs-keyword">int</span> n) : parent(n){
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span> ; i &lt; n ; i ++)
            parent[i] = i;
    }

    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">find</span><span class="hljs-params">(<span class="hljs-keyword">int</span> p)</span></span>{
        <span class="hljs-keyword">if</span>(p != parent[p])
            parent[p] = find(parent[p]);
        <span class="hljs-keyword">return</span> parent[p];
    }

    <span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">isConnected</span><span class="hljs-params">(<span class="hljs-keyword">int</span> p, <span class="hljs-keyword">int</span> q)</span></span>{
        <span class="hljs-keyword">return</span> find(p) == find(q);
    }

    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">unionElements</span><span class="hljs-params">(<span class="hljs-keyword">int</span> p, <span class="hljs-keyword">int</span> q)</span></span>{

        <span class="hljs-keyword">int</span> pRoot = find(p), qRoot = find(q);

        <span class="hljs-keyword">if</span>(pRoot == qRoot) <span class="hljs-keyword">return</span>;

        parent[pRoot] = qRoot;
    }
};

<span class="hljs-keyword">class</span> Solution {
<span class="hljs-keyword">public</span>:
 <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">bool</span>&gt; distanceLimitedPathsExist(<span class="hljs-keyword">int</span> n, <span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&gt;&amp; edgeList, <span class="hljs-built_in">vector</span>&lt;<span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&gt;&amp; queries) {

        <span class="hljs-comment">// &#x5BF9;&#x6240;&#x6709;&#x7684;&#x8FB9;&#x6309;&#x7167;&#x6743;&#x503C;&#x6392;&#x5E8F;</span>
        sort(edgeList.begin(), edgeList.end(), [](<span class="hljs-keyword">const</span> <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; e1, <span class="hljs-keyword">const</span> <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; e2){
           <span class="hljs-keyword">return</span> e1[<span class="hljs-number">2</span>] &lt; e2[<span class="hljs-number">2</span>];
        });

        <span class="hljs-comment">// &#x5BF9;&#x4E8E;&#x6240;&#x6709;&#x7684; query&#xFF0C;&#x628A;&#x8FD9;&#x4E2A; query &#x7684;&#x7D22;&#x5F15; i &#x6DFB;&#x52A0;&#x8FDB;&#x53BB;&#x3002;</span>
        <span class="hljs-comment">// &#x4E4B;&#x540E;&#x4F1A;&#x5BF9; query &#x6392;&#x5E8F;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528; query &#x539F;&#x6765;&#x7684;&#x7D22;&#x5F15;</span>
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; queries.size(); i ++)
            queries[i].push_back(i);

        <span class="hljs-comment">// &#x5BF9;&#x6240;&#x6709; query &#x6309;&#x7167; limit &#x8FDB;&#x884C;&#x6392;&#x5E8F;</span>
        sort(queries.begin(), queries.end(), [](<span class="hljs-keyword">const</span> <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; q1, <span class="hljs-keyword">const</span> <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">int</span>&gt;&amp; q2){
            <span class="hljs-keyword">return</span> q1[<span class="hljs-number">2</span>] &lt; q2[<span class="hljs-number">2</span>];
        });

        <span class="hljs-function">UF <span class="hljs-title">uf</span><span class="hljs-params">(n)</span></span>; <span class="hljs-comment">// &#x5E76;&#x67E5;&#x96C6;</span>
        <span class="hljs-built_in">vector</span>&lt;<span class="hljs-keyword">bool</span>&gt; res(queries.size());
        <span class="hljs-keyword">int</span> ep = <span class="hljs-number">0</span>; <span class="hljs-comment">// ep &#x8868;&#x793A;&#x5F53;&#x524D;&#x5904;&#x7406;&#x5230;&#x7684;&#x8FB9;&#x7684;&#x4F4D;&#x7F6E;</span>

        <span class="hljs-comment">// &#x6309;&#x7167; limit &#x4ECE;&#x5C0F;&#x5230;&#x5927;&#xFF0C;&#x4F9D;&#x6B21;&#x5904;&#x7406;&#x6BCF;&#x4E00;&#x4E2A; query</span>
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; queries.size(); i ++){

            <span class="hljs-comment">// &#x5C06;&#x8FD8;&#x6CA1;&#x6709;&#x6DFB;&#x52A0;&#x7684;&#xFF0C;&#x5C0F;&#x4E8E;&#x5F53;&#x524D; query &#x7684; limit &#x7684;&#x8FB9;&#x8FDB;&#x884C;&#x6DFB;&#x52A0;</span>
            <span class="hljs-keyword">while</span>(ep &lt; edgeList.size() &amp;&amp; edgeList[ep][<span class="hljs-number">2</span>] &lt; queries[i][<span class="hljs-number">2</span>])
                uf.unionElements(edgeList[ep][<span class="hljs-number">0</span>], edgeList[ep][<span class="hljs-number">1</span>]), 
                ep ++;

            <span class="hljs-comment">// &#x6DFB;&#x52A0;&#x4EE5;&#x540E;&#xFF0C;&#x770B;&#x5BF9;&#x4E8E;&#x8FD9;&#x4E2A; query &#x7684; p &#x548C; q&#xFF0C;&#x662F;&#x5426;&#x8FDE;&#x901A;</span>
            <span class="hljs-comment">// &#x6CE8;&#x610F;&#xFF0C;&#x7B54;&#x6848;&#x8981;&#x653E;&#x5230; res[queries[i][3]] &#x4E2D;&#xFF0C;&#x800C;&#x4E0D;&#x662F; res[i] &#x4E2D;</span>
            <span class="hljs-comment">// &#x56E0;&#x4E3A; queries &#x6570;&#x7EC4;&#x88AB;&#x6392;&#x8FC7;&#x5E8F;</span>
            res[queries[i][<span class="hljs-number">3</span>]] = uf.isConnected(queries[i][<span class="hljs-number">0</span>], queries[i][<span class="hljs-number">1</span>]);
        }
        <span class="hljs-keyword">return</span> res;
    }

};
</code></pre>

<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../数据结构/9.模板.html" class="navigation navigation-prev " aria-label="Previous page: 数据结构模板">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="1.时间复杂度.html" class="navigation navigation-next " aria-label="Next page: 1.时间复杂度">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"leetCode周赛记录","level":"4.1","depth":1,"next":{"title":"1.时间复杂度","level":"4.2","depth":1,"path":"算法/1.时间复杂度.md","ref":"算法/1.时间复杂度.md","articles":[]},"previous":{"title":"数据结构模板","level":"3.8","depth":1,"path":"数据结构/9.模板.md","ref":"数据结构/9.模板.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","sharing-plus","anchor-navigation-ex","favicon","expandable-chapters","toggle-chapters","back-to-top-button","code","-lunr","-search","search-pro","pageview-count","popup","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{},"expandable-chapters":{}},"theme":"default","author":"hzh","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"计算机 ,java , 大数据 基础知识体系","language":"zh-hans","gitbook":"3.2.3"},"file":{"path":"算法/leetCode周赛题解.md","mtime":"2020-12-20T13:16:44.801Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-30T11:12:56.611Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

